﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $('input[id*="txtFirstName"]:last').focus();
            $('input[id*="txtFirstName"]:last').click(function () {
                alert("F");
            });
            $("#gvContacts input:last").keypress(function (e) {
                if (e.which == 13) {
                    __doPostBack('link', '');
                    $('input[id*="txtFirstName"]:last').focus();
                }
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    <div>
        <h3>
            Insert Multiple Record in a SQL Database using ASP.Net application.</h3>
        <div style="padding: 10px 0px">
            No of record you want to insert :
            <asp:TextBox ID="txtNoOfRecord" runat="server"></asp:TextBox>
            &nbsp;
            <asp:Button ID="btnAddRow" runat="server" Text="Add Rows" OnClick="btnAddRow_Click"
                UseSubmitBehavior="false" />
            <asp:LinkButton ID="link" runat="server" OnClick="btnAddRow_Click" Text="ADD ROWS"></asp:LinkButton>
        </div>
        <asp:GridView ID="gvContacts" runat="server" AutoGenerateColumns="false" CellPadding="5">
            <Columns>
                <asp:TemplateField HeaderText="SL No.">
                    <ItemTemplate>
                        <%#Container.DataItemIndex +1 %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="First Name">
                    <ItemTemplate>
                        <asp:TextBox ID="txtFirstName" runat="server" Text='<%# Eval("masinhvien") %>'></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Last Name">
                    <ItemTemplate>
                        <asp:TextBox ID="txtLastName" runat="server" Text='<%# Eval("Ho") %>'></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Contact No">
                    <ItemTemplate>
                        <asp:TextBox ID="txtContactNo" runat="server" Text='<%# Eval("ten") %>'></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <div style="padding: 10px 0px;">
            <asp:Panel ID="Panel1" runat="server" Visible="false">
                <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
                &nbsp;<asp:Label ID="lblMsg" runat="server"></asp:Label>
            </asp:Panel>
        </div>
        <div>
            <b>Database Records</b>
            <div>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" CellPadding="5">
                    <Columns>
                        <asp:TemplateField HeaderText="SL No.">
                            <ItemTemplate>
                                <%#Eval("masinhvien") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="First Name">
                            <ItemTemplate>
                                <%#Eval("ho") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Last Name">
                            <ItemTemplate>
                                <%#Eval("ten") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Contact No">
                            <ItemTemplate>
                                <%#Eval("malop") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
